﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DAL;
using word.UserControls;
using Models;

namespace word.winform
{
    public delegate void setTextValue(string sql);
    public partial class SqlSelect : Form
    {
        public event setTextValue setFormTextValue;
        private String tableName;
        public String TableName
        {
            get { return tableName; }
            set { tableName = value; }
        }

        private String sql;

        public String Sql
        {
            get { return sql; }
            set { sql = value; }
        }

        public SqlSelect()
        {
            InitializeComponent();
        }

        private void btn_Ok_Click(object sender, EventArgs e)
        {
            setFormTextValue(RTB_Sql.Text.ToString());
            this.Close();
            return;
        }

        private void SqlSelect_Load(object sender, EventArgs e)
        {
            TB_ShowTableName.Text = TableName;
            DGV_Show.DataSource = DBHelper.Select("SELECT * FROM "+TableName);
        }
    }
}
